<?php
//
//	file: includes/aucp/color_plugs.php
//	begin: 30/04/2007
//	$Author: christopher $
//	$Revision: 29 $
//	$Date: 2008-07-19 15:59:35 +0000 (Sat, 19 Jul 2008) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	description: color plugs

if (!defined('IN_PHPBB'))
{
	die("Hacking attempt");
}

class color_cache extends plug_ins
{
	function start()
	{
		global $cache_table_list;

		$cache_table_list['color'] = 'color_handler';

		return;
	}
}

class color_header extends plug_ins
{
	function start()
	{
		global $colors;

		if ( is_object($colors) )
		{
			$colors->generate_css();
		}

		return;
	}
}

class color_members extends plug_ins
{
	function do_read($mode)
	{
		global $sql;

		$sql = str_replace('SELECT ', 'SELECT user_group_id, user_session_time, ', $sql);

		return;
	}

	function display($row, $tpl_switch='')
	{
		global $template, $colors;

		$template->assign_lastblock_vars($tpl_switch, array(
			'S_USERNAME' => $colors->get_user_color($row['user_group_id'], $row['user_session_time']),
		));

		return;
	}

}

class color_mods extends plug_ins
{
	function display($row, $tpl_switch='')
	{
		global $template, $user, $colors;

		$template->assign_lastblock_vars($tpl_switch . '.mod', array(
			'L_MOD' => ($row['mod_type'] == POST_USERS_URL) ? $colors->get_user_color($row['mod_user_group_id'], $row['mod_user_session_time'], $row['mod_name']) : $colors->get_user_color($row['mod_id'], '0', ($row['mod_system'] ? $user->lang($row['mod_name']) : $row['mod_name'])),
		));

		return;
	}

}

class color_profile extends plug_ins
{
	function view()
	{
		global $colors, $template, $profiledata, $user;

		$template->assign_vars(array(
			'USERNAME' => $colors->get_user_color($profiledata['user_group_id'], $profiledata['user_session_time'], $profiledata['username']),
			'L_VIEWING_PROFILE' => sprintf($user->lang('Viewing_user_profile'), $colors->get_user_color($profiledata['user_group_id'], $profiledata['user_session_time'], $profiledata['username'])),
		));

		return;
	}
}

class color_stats extends plug_ins
{
	function display($row, $switch)
	{
		global $template, $user, $colors;

		$username = ($row['username']) ? $row['username'] : $user->lang('Guest');
		$s_username = $colors->get_user_color($row['user_group_id'], $row['user_session_time']) : $colors->get_user_color(GROUP_ANONYMOUS);

		$template->assign_lastblock_vars($switch, array(
			'USERNAME' => $username,
			'S_USERNAME' => $s_username,
		));

		return;
	}
}

class color_version
{
	function read(&$data)
	{
		$data[] = array('app_name' => 'AUCP Colors', 'app_desc' => '', 'app_marker' => 'mod_aucp_color', 'app_author' => 'impleri', 'app_author_url' => 'http://impleri.net/', 'app_server' => 'mods.impleri.net', 'app_file' => '/download/versions.dta', 'app_protocol' => 'native', 'app_page' => 'http://mods.impleri.net/download.php');
	}
}
?>